#ifndef _PARAMETER_COMMON_H
#define _PARAMETER_COMMON_H
#include <lib/cassert.h>
#include "parameter.h"

typedef struct parameter_table_info {
	uint32_t offset;
	uint32_t magic;
}__attribute__((aligned(sizeof(unsigned long)))) parameter_table_info_t;

typedef struct head_config {
    uint32_t magic;
	uint32_t version;
	uint32_t size;
	uint8_t rev1[4];

	char pack_time[32];
	uint32_t table_count;
	parameter_table_info_t table[PARAMETER_COUNT];
}__attribute__((aligned(sizeof(unsigned long)))) head_config_t;

#define HEAD_MAGIC_OFFSET					0x00
#define HEAD_VERSION_OFFSET					0x04
#define HEAD_SIZE_OFFSET					0x08
#define HEAD_PACK_TIME_OFFSET				0x10
#define HEAD_TABLE_COUNT_OFFSET				0x30
#define HEAD_TABLE_INFO_OFFSET				0x38

#define CM_CASSERT( offset, _member)						\
	 	CASSERT(offset ==									\
		 __builtin_offsetof(head_config_t, _member),		\
		 assert_##offset##_mismatch)

CM_CASSERT(HEAD_MAGIC_OFFSET, magic);
CM_CASSERT(HEAD_VERSION_OFFSET, version);
CM_CASSERT(HEAD_SIZE_OFFSET, size);
CM_CASSERT(HEAD_PACK_TIME_OFFSET, pack_time);
CM_CASSERT(HEAD_TABLE_COUNT_OFFSET, table_count);
CM_CASSERT(HEAD_TABLE_INFO_OFFSET, table[0]);

#endif